/*
 * @Author: lll 1280388921@qq.com
 * @Date: 2025-05-13 00:01:47
 * @LastEditors: lll 1280388921@qq.com
 * @LastEditTime: 2025-05-13 13:54:10
 * @FilePath: /lesson40/2.ThreadPool/main.cc
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
#include <iostream>
#include <unistd.h>
#include <pthread.h>
#include <string>
#include <ctime>

#include "ThreadPool.hpp"
#include "Task.hpp"

using namespace std;

int main()
{
    ThreadPool<Task> *tp = new ThreadPool<Task>(5);
    tp->Start();
    srand(time(nullptr)^getpid());
    int len=opers.size();
    while (1)
    {
        int x=rand()%10+1;
        usleep(10);
        int y=rand()%5;
        char op=opers[rand()%len];
        //1.构建任务
        Task t(x,y,op);
        sleep(1);

        //2.交给线程处理
        tp->Push(t);
        cout<<"main thread is make task.."<<t.GetTask()<<endl;
        sleep(1);
    }

    return 0;
}